<style>

</style>
<div class="layui-layout order-wrapper" style="padding:0 20px;">
    <div id="search-wrapper">
        <div class="layui-form">
            <div class="layui-row">
                <div class="layui-inline fr">
                    <button class="layui-btn layui-btn-normal export">导出</button>
                </div>
            </div>
        </div>
    </div>
    <table class="layui-hide" id="table_list" lay-filter="table_filter">
    </table>
</div>
<script>
    layui.use(['table','form'], function(){
        var table = layui.table;
        var $ = layui.$;
        //方法级渲染
        table.render({
            elem: '#table_list'
            ,url: '/gift/table?userId=' + {{.userId}}
            ,cols: [[
                {field:'sort', title: '序号', align:'center',width:'100'},
                {field:'userId', title: '用户Id', align:'center',width:'120'},
                {field:'nickname', title: '用户名', align:'center',width:'150'},
                {field:'date', title: '发生时间', align:'center',width:'250',sort:true},
                {field:'operateId', title: '操作员Id', align:'center',width:'120'},
                {field:'operator', title: '操作员', align:'center',width:'150'},
                {field:'type', title: '发生事由', align:'center',width:'120'},
                {field:'vip', title: 'Vip时长', align:'center',width:'120'},
                {field:'coin', title: '书币', align:'center',width:'120'},
                {field:'gift', title: '书券', align:'center',width:'120'},
                {field:'reason', title: '赠送事由', align:'center',width:'295'}
            ]]
            ,id: 'listReload'
            ,page: {
                curr: location.hash.replace('#!fenye=', '') //获取起始页
                ,hash: 'fenye' //自定义hash值
            }
            ,height: "full-200"
        });

        var active = {
            reload: function(){
                table.reload('listReload', {
                    where: {
                        userId:$(".Id").val(),
                        name:$(".name").val()
                    }
                    ,page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            }
        };


        // $('#search-wrapper .search').on('click', function(){
        //     var type = $(this).data('type');
        //     active[type] ? active[type].call(this) : '';
        //
        // });

        $(".export").click(function(){
            var urlParam = "?page=1&limit=99999&userId=" + {{.userId}} + "&export=1";
            window.open('/gift/table'+urlParam)
        });
    });

</script>